// 定义一个普通的类用于存储数据
import 'dart:convert';

class FuelRecordData {
  final String refuelingTime;
  final double totalMileage;
  final double remainingMileage;
  final double refuelingCost;
  final double discountAmount;
  final double paymentAmount;
  final double oilPrice;
  final double refuelingVolume;
  final bool isLastRecorded;

  FuelRecordData({
    required this.refuelingTime,
    required this.totalMileage,
    required this.remainingMileage,
    required this.refuelingCost,
    required this.discountAmount,
    required this.paymentAmount,
    required this.oilPrice,
    required this.refuelingVolume,
    required this.isLastRecorded,
  });


  // 将对象转换为 Map
  Map<String, dynamic> toMap() {
    return {
      'refuelingTime': refuelingTime,
      'totalMileage': totalMileage,
      'remainingMileage': remainingMileage,
      'refuelingCost': refuelingCost,
      'discountAmount': discountAmount,
      'paymentAmount': paymentAmount,
      'oilPrice': oilPrice,
      'refuelingVolume': refuelingVolume,
      'isLastRecorded': isLastRecorded,
    };
  }

  // 将对象转换为 JSON 字符串
  String toJson() {
    return json.encode(toMap());
  }
}